//
//  XS_Font.swift
//  WorkDemo
//
//  Created by 韩云智 on 2019/9/30.
//  Copyright © 2019 韩云智. All rights reserved.
//

import Foundation
import UIKit

public extension UIFont {
    /// 字体名称
    enum XS_FontName: String {
        case `default`
        case regular = "PingFangSC-Regular"
        case medium = "PingFangSC-Medium"
        case light = "PingFangSC-Light"
        case semibold = "PingFangSC-Semibold"
        
//        case regular = "SourceHanSansCN-Regular"
        case arial = "ArialMT"
        case arialRounded = "ArialRoundedMTBold"
        case bdt27 = "字魂27号-布丁体"
    }
    
    /// 生成字体
    /// - Parameter name: 字体名称, 默认系统字体
    /// - Parameter size: 字体大小
    static func xsFont(name: XS_FontName = .regular, _ size: CGFloat) -> UIFont {
        guard name != .default else {
            return UIFont.systemFont(ofSize: size)
        }
        return xsNFont(name: name.rawValue, size)
    }
    static func xsNFont(name: String, _ size: CGFloat) -> UIFont {
        guard let font = UIFont(name: name, size: size) else {
            return UIFont.systemFont(ofSize: size)
        }
        return font
    }
}
